<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>秒杀结果等待页</title>
</head>
<!-- jquery -->
<script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
<!-- bootstrap -->
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap/css/bootstrap.min.css}"/>
<script type="text/javascript" th:src="@{/bootstrap/js/bootstrap.min.js}"></script>
<!-- layer -->
<script type="text/javascript" th:src="@{/layer/layer.js}"></script>
<!-- common.js -->
<script type="text/javascript" th:src="@{/js/common.js}"></script>
<body>
<h3 id="text">正在进行秒杀，请稍等......</h3>
<input type="hidden" id="goodsId" th:value="${goodsId}" />
<script>
    var goodsId=parseInt($("#goodsId").val());

    function selectOrder(goodsId){
        $.get("/seckill/result", {"goodsId":goodsId},function (e){
            debugger;
           var result =e.object;
           if (result.length>10){
               $("#text").html("恭喜你,秒杀成功!,<a href='/seckillOrder/toOrderDetail?orderId="+result+"'>点击查看订单</a>");

           }else if (result=="0"){
               setTimeout(selectOrder(goodsId),500)
           }else {
               layer.msg("商品已经被抢完咯！")
           }

        })
    }

   $(function (){
       selectOrder(goodsId);
   })
</script>
</body>
</html>